package com.hnkywl.sts.action.report;

import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.service.report.CwflSfcService;
import com.hnkywl.sts.service.sys.GnczService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-17
 * Time: 下午8:19
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/report/cwflsfc")
public class CwflSfcAction extends SimpleActionSupport {
    private Long gsId;
    private Integer year;
    private Integer month;
    private Date date;
    private CwflSfcService cwflSfcService;

    //功能操作
    private List<Gncz> gnczList;
    private GnczService gnczService;

    @Action("cwflsfc")
    public String cwsfc() {
        gnczList = gnczService.findGnczByJsAndUrl(request.getServletPath());
        date = new Date();
        return SUCCESS;
    }

    @Action("cwflsfcList")
    public void cwkcList() {
        String json = cwflSfcService.cwflSfcList(gsId, year, month);
        renderJson(json);
    }

    @Action("ymjz")
    public void kcspflSfcYmjz() {
        try {
            String errorMsg = cwflSfcService.kcspflSfcYmjz(year, month);
            if (StringUtils.isEmpty(errorMsg))
                renderJson("{\"statusCode\":\"200\", \"message\":\"操作成功!\"}");
            else
                renderJson("{\"statusCode\":\"300\", \"message\":\"" + errorMsg + "\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderJson("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }

    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public Integer getMonth() {
        return month;
    }

    public void setMonth(Integer month) {
        this.month = month;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }

    @Autowired
    public void setGnczService(GnczService gnczService) {
        this.gnczService = gnczService;
    }

    @Autowired
    public void setCwflSfcService(CwflSfcService cwflSfcService) {
        this.cwflSfcService = cwflSfcService;
    }
}
